//
//  CZUploadTaskTextViewController.m
//  nsj_iOS
//
//  Created by apple on 2017/2/20.
//  Copyright © 2017年 GCZ. All rights reserved.
//

#import "CZUploadTaskTextViewController.h"

@interface CZUploadTaskTextViewController ()
@property (weak, nonatomic) IBOutlet UITextField *titleTF;
@property (weak, nonatomic) IBOutlet UITextView *contentTV;
@end

@implementation CZUploadTaskTextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"上传故事";
    UIButton *rightBarBtn = [UIButton buttonWithType:(UIButtonTypeSystem)];
    rightBarBtn.frame = CGRectMake(0, 0, 54, 25);
    [rightBarBtn addTarget:self action:@selector(saveText) forControlEvents:(UIControlEventTouchUpInside)];
    rightBarBtn.backgroundColor = mRGBColor(214, 221, 220);
    [rightBarBtn setTitle:@"保存" forState:(UIControlStateNormal)];
    rightBarBtn.layer.cornerRadius = 2;
    rightBarBtn.clipsToBounds = YES;
    rightBarBtn.tintColor = ThemeColor;
    rightBarBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBarBtn];
    self.titleTF.borderStyle = UITextBorderStyleNone;
    
    if (self.novelTitle.length > 0) {
        self.titleTF.text = self.novelTitle;
    }
    if (self.content.length > 0) {
        self.contentTV.text = self.content;
    }
    // Do any additional setup after loading the view from its nib.
}

- (void)saveText {
    if (self.titleTF.text.length < 1) {
        [SVProgressHUD showErrorWithStatus:@"请输入故事标题"];
        return;
    }
    
    if (self.contentTV.text.length < 1) {
        [SVProgressHUD showErrorWithStatus:@"请输入故事内容"];
        return;
    }
    
    
    if (self.saveTextBlock) {
        self.saveTextBlock(self.titleTF.text, self.contentTV.text);
    }
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
